package com.bdqn.reflect.model;

/**
 * Driver
 *
 * @author LILIBO
 * @since 2025/1/3
 */
public class Driver {

    private Car car;

    public Driver(Car car) {
        this.car = car;
    }

    public void startCar() {
        // 现在 Driver 只需要知道 Car 提供的方法
        car.start();
    }

    public static void main(String[] args) {
        Driver driver = new Driver(new Car());
        driver.startCar();
    }

}

// 改进后的示例
class Engine {

    public void start() {
        System.out.println("Engine started");
    }

}

class Car {

    private Engine engine;

    public Car() {
        this.engine = new Engine();
    }

    // Car 提供的一个高层方法，隐藏 Engine 的实现细节
    public void start() {
        engine.start();
    }

}

